<template>
  <div class="school">
    <h2>学校名称：{{ name }}</h2>
    <h2>学校地址：{{ address }}</h2>
  </div>
</template>

<script>
import pubsub from 'pubsub-js';

export default {
  name: "School",
  data() {
    return {
      name: '测试名称',
      address: '测试地址'
    }
  },
  mounted() {
    this.pubId = pubsub.subscribe('hello', function (msg, data) {
      console.log('hello订阅消息')
      console.log(data);
    })
  },
  beforeDestroy() {
    pubsub.unsubscribe(this.pubId);
  }
}
</script>

<style scoped>
.school {
  padding: 10px;
  background-color: #5bc0de;
  margin-top: 10px;
}
</style>